<template>
  <div>
    <el-form
      ref="form"
      :rules="rules"
      :model="form"
      label-width="100px"
      label-position="left"
    >
      <!-- <el-form-item label="会员ID:" prop="phone">
        <el-select
          v-model="form.phone"
          style="width: 100%"
          placeholder="请选择会员ID"
        >
          <el-option
            v-for="(item, index) in memberList"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="充值金额:" prop="coin">
        <el-input v-model="form.coin" type="number" placeholder="请输入充值金额"></el-input>
      </el-form-item>
      <el-form-item label="订单流水号:" prop="order">
        <el-input v-model="form.order" type="number" placeholder="请输入订单流水号"></el-input>
      </el-form-item>
      <el-form-item label="备注:" prop="msg">
        <el-input v-model="form.msg" type="textarea" rows="5" maxlength="200" show-word-limit placeholder="请输入备注"></el-input>
      </el-form-item>
      <!-- <el-form-item label="类型:" prop="status">
        <el-radio-group v-model="form.status">
          <el-radio :label="1">充值</el-radio>
          <el-radio :label="0">扣款</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="变更金额:" prop="coin">
        <el-input v-model="form.coin" placeholder="请输入变更金额"></el-input>
      </el-form-item>
      <el-form-item label="商品:" prop="goods">
        <el-input v-model="form.goods" placeholder="请输入商品"></el-input>
      </el-form-item> -->
    </el-form>
    <div class="flexend">
      <el-button type="primary" @click="onSubmit">确 认</el-button>
      <el-button @click="resetForm">重 置</el-button>
    </div>
  </div>
</template>

<script>
import { validPhone } from "@/utils/validate";
import { userPay } from '@/api/member'
export default {
  data() {
    return {
      memberList: [
        { label: "15616011111", value: 1 },
        { label: "15600001111", value: 2 },
      ],
      form: {
        user_id: "",
        coin: "",
        order: "",
        msg: '',
      },
      rules: {
        phone: [
          { required: true, message: "请选择会员ID", trigger: "change" },
        ],
        coin: [{ required: true, message: "请输入充值金额", trigger: "blur" }],
        order: [{ required: true, message: "请输入订单流水号", trigger: "blur" }],
        msg: [{ required: true, message: "请输入备注信息", trigger: "blur" }],
        // status: [{ required: true, message: "请选择类型", trigger: "change" }],
      },
    };
  },
  props:{
    id:{
      require: true,
      default:''
    }
    // row:{
    //    type:Boolean,
    //    default:true
    // }
  },
  created(){
    this.form.user_id = this.id
  },
  methods: {
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (!valid) return;
        userPay(this.form).then(res=>{
          this.$modal.msgSuccess("充值成功");
          this.$emit('close',1)
        })
      });
    },

    resetForm() {
      this.$refs.form.resetFields();
    },
  },
};
</script>